<template>
	<view>
		
		<view class="InfoBox bgfff">
			<view class="OriginalPrice">原价：{{ListInfo[0].cost_price}}</view>
			<view class="DiscountPrice">套餐价：{{ListInfo[0].price}}（为您节省<text class="red">{{(ListInfo[0].cost_price-ListInfo[0].price).toFixed(2)}}</text>元）</view>
		</view>
		
		<view class="ListBox">
			<view class="List bgfff flexBox" v-for="(item,index) in ListInfo[0].goods_list" :key="index">
				<view class="ImgBox"><image :src="item.image" mode=""></image></view>
				<view class="Info" >
					<view class="Name">{{item.name}}</view>
					<view class="">
						<view class="Original">原价：￥{{item.shop_price}}</view>
						<view class="Discount">优惠价：<text class="red">￥{{item.price}}</text></view>
					</view>
				</view>
			</view>
		</view>
		
		
		<view class="BottomBox flexBox">
			<view class="PriceBox red">
				￥{{ListInfo[0].price}}
			</view>
			<view class="purchase" @click="addcar()">
				加入购物车
			</view>
		</view>
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bl_id:"",
				goods_id:"",
				ListInfo:"",
			}
		},
		onLoad(e) {
			if(e.b_id){
				this.bl_id=e.b_id;
			}
			if(e.goods_id){
				this.goods_id=e.goods_id;
			}
		},
		created() {
			this.getList();
		},
		methods: {
			addcar(){
				let that=this;
				this.$util.request({
					url:'/mobile/index.php?act=member_cart&op=cart_add',
					method:'POST',
					data:{
						// goods_id:this.goods_id,
						// quantity :1,
						// goods_type:this.goods_type,
						// promotions_id:this.promotions_id,
						bl_id:that.bl_id
					}
				}).then(res=>{
					if(res.datas=='1'){
						uni.showToast({
							title:'加入成功！'
						})
					}else{
						uni.showToast({
							title:res.message,
							icon:'none'
						})
					}
				})
			},
			getList(){//获取套餐信息
				let that = this;
				this.$util.request({
						url: '/mobile/index.php?act=goods&op=get_bundling',
						method: 'get',
						data: {
							goods_id:that.goods_id,
							bl_id:that.bl_id
						},
					}).then(function(res) {
							// console.log(res);
							that.ListInfo=res.datas.b_list
					})
			}
		}
	}
</script>

<style>
	.flexBox{
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.bgfff{
		background-color: #FFFFFF;
	}
	.InfoBox{
		border-top: 1rpx solid #EEEEEE;
		padding: 20rpx 40rpx;
		color: #333333;
		font-weight: bold;
	}
	.red{
		color: red;
	}
	 .Info{
		width: 500rpx;
		}
	.ListBox{
		margin-bottom: 130rpx;
	}
	.ListBox .List{
		margin-top: 20rpx;
		padding: 20rpx 40rpx;
	}
	.ListBox .ImgBox image{
		width: 170rpx;
		height: 170rpx;
		margin-right: 20rpx;
	}
	.Info .Name,.Info .Original,.Info .Discount{
		line-height: 40rpx;
		color: #999999;
	}
	.Info .Name{
		color: #333333;
		font-weight: bold;
		height: 80rpx;
		overflow: hidden;
		display: -webkit-box;
		-webkit-box-orient:vertical;
		-webkit-line-clamp:2;
	}
	.Info .Original{
		margin-top: 10rpx;
		}
	.BottomBox{
		height: 100rpx;
		width: 100%;
		position: fixed;
		bottom: 0;
		background-color: #FFFFFF;
		z-index: 999999;
	}
	.BottomBox .PriceBox{
		width: 450rpx;
		text-align: right;
	}
	.BottomBox .purchase{
		background-color: #e5258e;
		color: #FFFFFF;
		line-height: 100rpx;
		width: 250rpx;
		text-align: center;
	}
</style>
